<HTML>
<BODY>
<PRE>
<!-- Manpage converted by man2html 3.0.1 -->

<B><A HREF="STRSEP.html">STRSEP(3)</A></B>	       FreeBSD Library Functions Manual 	     <B><A HREF="STRSEP.html">STRSEP(3)</A></B>


</PRE>
<H2>NAME</H2><PRE>
     <B>strsep</B> - separate strings


</PRE>
<H2>SYNOPSIS</H2><PRE>
     <B>#include</B> <B>&lt;string.h&gt;</B>

     <I>char</I> <I>*</I>
     <B>strsep</B>(<I>char</I> <I>**stringp</I>, <I>const</I> <I>char</I> <I>*delim</I>)


</PRE>
<H2>DESCRIPTION</H2><PRE>
     The <B>strsep</B>() function locates, in the string referenced by <I>*stringp</I>, the
     first occurrence of any character in the string <I>delim</I> (or the terminating
     `\0' character) and replaces it with a `\0'. The location of the next
     character after the delimiter character (or NULL, if the end of the
     string was reached) is stored in <I>*stringp</I>. The original value of <I>*stringp</I>
     is returned.

     An ``empty'' field, i.e. one caused by two adjacent delimiter characters,
     can be detected by comparing the location referenced by the pointer re-
     turned in <I>*stringp</I> to `\0'.

     If <I>*stringp</I> is initially NULL, <B>strsep</B>() returns NULL.


</PRE>
<H2>EXAMPLES</H2><PRE>
     The following uses <B>strsep</B>() to parse a string, containing tokens delimit-
     ed by white space, into an argument vector:

	   char **ap, *argv[10], *inputstring;

	   for (ap = argv; (*ap = strsep(&amp;inputstring, " \t")) != NULL;)
		   if (**ap != '\0')
			   if (++ap &gt;= &amp;argv[10])
				   break;


</PRE>
<H2>HISTORY</H2><PRE>
     The <B>strsep</B>() function is intended as a replacement for the <B>strtok</B>() func-
     tion.  While the <B>strtok</B>() function should be preferred for portability
     reasons (it conforms to ISO 9899: 1990 (``ISO C'')) it is unable to han-
     dle empty fields, i.e. detect fields delimited by two adjacent delimiter
     characters, or to be used for more than a single string at a time.  The
     <B>strsep</B>() function first appeared in 4.4BSD.

BSD				 June 9, 1993				     1
</PRE>
<HR>
<ADDRESS>
Man(1) output converted with
<a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
</ADDRESS>
</BODY>
</HTML>
